package com.linsir.core;

/**
 * @ProjectName:linsir-lin
 * @Package:com.linsir.core
 * @Title: BaseResponse
 * @Description: TODO
 * @Create:2021/6/5 12:51 by @author:Linsir
 * @Update:2021/6/5 12:51 by @author:Linsir
 * @UpdateRemark: 初始创建
 * @Version 1.0.0
 */
public class BaseResponse<T> {

   private CodeEnum codeEnum;

   private String msg;

   private T data;

    public CodeEnum getCodeEnum() {
        return codeEnum;
    }

    public void setErrorCodeEnum(CodeEnum codeEnum) {
        this.codeEnum = codeEnum;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public BaseResponse(CodeEnum codeEnum, String msg, T data)
   {
      this.setErrorCodeEnum(codeEnum);
      this.setData(data);
      this.setMsg(msg);
   }

    public static <T> BaseResponse<T> success(String message, T data) {
        return new BaseResponse<T>(CodeEnum.SUCCESS, message, data);
    }

    public static <T> BaseResponse<T> error(String message, T data) {
        return new BaseResponse<T>(CodeEnum.FAILED, message, data);
    }



}
